<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->title}</title>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/admin.css" rel="stylesheet" type="text/css" />
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/common/tooltip.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.tooltip.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.boxy.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/common.js"></script>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/common/boxy.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
th {
	text-align:right;
}
td {
	text-align:left;
}
.template { border:none; border-bottom:1px #999 solid; }
-->
</style>

</head>
<body>

<div class="wrapper">
  <div class="title shadow titleBg">
    <table width="100%" border="0" cellspacing="1">
      <tr>
        <td><h1> {:$i->title} => {:if $i->p[0] eq "mod"}修改{:elseif $i->p[0] eq "add"}
            添加{:/if} </h1></td>
      </tr>
    </table>
  </div>
  <div class="content shadow">
    <form id="form1" method="post" action="{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/{:if $i->p[0] eq "mod"}update/{:$i->p[1]}{:elseif $i->p[0] eq "add"}insert/0{:/if}/{:$i->p[2]}/{:$i->p[3]}" target="actionFrame" onsubmit="javascript:return actionFrame();">
      <table width="100%" border="0" cellspacing="1">
        <tr>
          <th width="20%">完整标题：</th>
          <td width="80%"><input class="inputtitle" name="title" type="text" size="60" id="title" value="" />
            *</td>
        </tr>
        <tr>
          <th width="20%">简短标题：</th>
          <td width="80%"><input class="inputtitle" name="briefTitle" type="text" size="40" id="briefTitle" value="" title="可不填，默认和完整标题相同" />
            <select name="color" id="color">
              <option value="">颜色</option>
              <option value="#000" style="background-color:#000"></option>
              <option value="#fff" style="background-color:#fff"></option>
              <option value="green" style="background-color:green"></option>
              <option value="maroon" style="background-color:maroon"></option>
              <option value="olive" style="background-color:olive"></option>
              <option value="navy"  style="background-color:navy"></option>
              <option value="purple" style="background-color:purple"></option>
              <option value="gray" style="background-color:gray"></option>
              <option value="#ff0" style="background-color:#ff0"></option>
              <option value="#0f0" style="background-color:#0f0"></option>
              <option value="#0ff" style="background-color:#0ff"></option>
              <option value="#f0f" style="background-color:#f0f"></option>
              <option value="red"  style="background-color:red"></option>
              <option value="#00f" style="background-color:#00f"></option>
              <option value="teal" style="background-color:teal"></option>
            </select>
            (在列表中显示)</td>
        </tr>
        <tr>
          <th width="20%">属　性：</th>
          <td width="80%"><input class='noBorder' type='checkbox' name='flag[]' id='flagsh' value='h'><label for="flagsh">
            头条[h]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagsc' value='c'><label for="flagsc">
            推荐[c]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagsp' value='p'><label for="flagsp">
            图文[p]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagsf' value='f'><label for="flagsf">
            幻灯[f]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagss' value='s'><label for="flagss">
            滚动[s]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagsj' value='j'><label for="flagsj">
            跳转[a]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagsb' value='b'><label for="flagsb">
            加粗[b]</label></td>
        </tr>
        <tr class="j hidden">
          <th width="20%">跳转地址：</th>
          <td width="80%"><input name="redirectUrl" type="text" size="60" id="redirectUrl" value="" />
            *</td>
        </tr>
        <tr class="notJ">
          <th width="20%">副标题：</th>
          <td width="80%"><input name="viceTitle" type="text" size="60" id="viceTitle" value="" /></td>
        </tr>
        <tr>
          <th>缩略图：</th>
          <td><input title="点击查看图片" name="thumb" type="text" size="50" id="thumb" value="{:$i->data->thumb}" /> 【<a href='#' title="上传图片" id="upload">上传图片</a>】</td>
        </tr>
        <tr class="notJ">
          <th>栏　目：</th>
          <td><select name="categoryId" id="categoryId">
          <option value="">--请选择栏目--</option>
              {:foreach item=item from=$i->category}
            <option {:$item->style} value="{:$item->id}" {:if $item->id == $i->categoryId}selected="selected"{:/if}>{:$item->name}</option>
            {:/foreach}
            </select>
            * (不能选灰色背景的栏目)</td>
        </tr>
        {:field fields=$i->addFields}
        <tr class="notJ">
          <th width="20%">{:$name}：</th>
          <td width="80%"> {:$code} </td>
        </tr>
        {:/field}
        <tr class="notJ">
          <th>作　者：</th>
          <td><input name="author" type="text" size="30" id="author" value="" /></td>
        </tr>
        <tr class="notJ">
          <th>来　源：</th>
          <td><input name="source" type="text" size="30" id="source" value="" /></td>
        </tr>
        <tr class="notJ">
          <th width="20%">关键词：</th>
          <td width="80%"><input name="keywords" type="text" size="50" id="keywords" value="" />
            (多个时用空格隔开)</td>
        </tr>
        <tr class="notJ">
          <th width="20%">摘　要：</th>
          <td width="80%"><textarea name="desc" cols="58" rows="4" id="desc"></textarea></td>
        </tr>
        <tr>
          <th>文档排序：</th>
          <td>
          <select name="ordering" id="ordering">
            <option value="0" selected="selected">默认排序</option>
                <option value="7">置顶一周</option>
                <option value="15">置顶半个月</option>
                <option value="30">置顶一个月</option>
                <option value="90">置顶三个月</option>
                <option value="180">置顶半年</option>
                <option value="360">置顶一年</option>
            </select></td>
        </tr>
        <tr class="notJ">
          <th>列表显示：</th>
          <td>
          <label><input class="noBorder" name="listed" type="radio" value="1" checked="checked" />是</label>  <label><input name="listed" class="noBorder" type="radio" value="0" />否</label> 
            (如果选否则不会在首页和列表页中出现)</td>
        </tr>
        <tr class="notJ">
          <th>访问权限：</th>
          <td><select name="visit" id="visit">
              <option value="0" selected="selected">无任何访问限制</option>
              <option value="1">VIP1及以上等级</option>
              <option value="2">VIP2及以上等级</option>
              <option value="3">VIP3及以上等级</option>
              <option value="4">VIP4及以上等级</option>
              <option value="5">VIP5及以上等级</option>
              <option value="6">VIP6及以上等级</option>
              <option value="-1">禁止任何人访问</option>
            </select></td>
        </tr>
        <tr class="notJ">
          <th width="20%">发布日期：</th>
          <td width="80%"><input name="pubTime" type="text" size="20" id="pubTime" value="{:$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
" /></td>
        </tr>
        <tr>
          <th>&nbsp;</th>
          <td><input type="submit" id="submit" value=" 提 交 " />
            &nbsp;
            <input type="reset" onclick="history.go(-1);" value=" 返 回 " /></td>
        </tr>
      </table>
    </form>
  </div>
</div>
<script language="javascript" type="text/javascript">

$("#flagsj").click(
	function () {
		if(this.checked){
			$(".j").show();
			$(".notJ").hide();
		}else{
			$(".j").hide();
			$(".notJ").show();				
		}
	}
);

$("#upload").click(
	function () {
		if($("#uploadFrame").tpl()===null)
		{
			$("select").hide();
			new Boxy('<iframe id="uploadFrame" src="{:$smarty.const.BOOT_URL}/file/upload/show" width="400" height="100" frameborder="0" scrolling="no"></iframe>', {title:'上传图片', afterHide:function() {remove();}});
			return false;
		}
	}
);

$("#thumb").focus(
	function () {
		if($.trim($("#thumb").get(0).value)!='')
		{
			new Boxy('<img src="'+$("#thumb").get(0).value+'">', {title:'缩略图'});
		}
	}
);

$("#thumb").blur(
	function () {
		$(".boxy-wrapper").hide("fast");
	}
);

function hide(){
	$(".boxy-wrapper").remove();
	Boxy.DEFAULTS.title = '上传成功';
	new Boxy('<img src="'+$("#thumb").get(0).value+'">');
	window.setTimeout("doHide();",2000);
}

function actionFrame() {
	$("#submit").get(0).disabled=true;
	new Boxy('<iframe frameborder="0" scrolling="auto" width="330" height="120" id="actionFrame" name="actionFrame"></iframe>', {title:'提示信息',closeable:false});
	return true;
}

function hideAlertTrue(){
	$(".boxy-wrapper").remove();
	window.location.href='{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/lists';
	return true;
}

function hideAlertFalse(){
	$(".boxy-wrapper").remove();
	$("#submit").get(0).disabled=false;
	return false;
}

function doAgain(){
	$(".boxy-wrapper").remove();
	window.location.href='{:$smarty.const.BOOT_URL}/{:$i->Uri->getPathInfo()}';
	return true;
}

function listMore(){
	$(".boxy-wrapper").remove();
	window.location.href='{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/lists';
	return true;
}

function doHide(){
	$(".boxy-wrapper").hide("slow");
	remove();
}

function upload(url){
	$('#thumb').val(url);
}

$("#addNode").click(
	function () {
		$("select").hide();
		if($('#newNodeName').tpl()===null)
		{
			new Boxy('<form action="" method="get">节点名称：<input type="text" name="newNodeName" id="newNodeName" value="" /> [<a href="#@" onclick="newNode();return false;">确定</a>]</form>', {title:'增加节点', afterHide:function() {remove();}});
		}
        return false;
	}
);


$("#addArchive").click(
	function () {
		if($("#addArchiveFrame").tpl()===null)
		{
			$("select").hide();
			new Boxy('<iframe id="addArchiveFrame" src="{:$smarty.const.BOOT_URL}/Archive/archive/lists/0/0/0/0/select/insertSpecIds" width="620" height="400" frameborder="0" scrolling="auto"></iframe>', {title:'选择文档', afterHide:function() {remove();}});
			return false;
		}
	}
);

$("#addRelative").click(
	function () {
		if($("#addRelativeFrame").tpl()===null)
		{
			$("select").hide();
			new Boxy('<iframe id="addRelativeFrame" src="{:$smarty.const.BOOT_URL}/Archive/archive/lists/0/0/0/0/select/insertRelativeIds" width="620" height="400" frameborder="0" scrolling="auto"></iframe>', {title:'选择文档', afterHide:function() {remove();}});
			return false;
		}
	}
);

function remove()
{
	$(".boxy-wrapper").remove();
	$("select").show();
}

function newNode(){
	var startBr="\n";
	if($("#newNodeName").val()=='')
	{
		alert('节点名称不能为空');	
		return false;
	}
	if($("#specCode").val()==''){
		startBr="";
	}
	$("#specCode").val($("#specCode").val()+startBr+$("#newNodeName").val()+":");
	remove();
	return false;
}

var textObj;

function insertSpecIds(ids){
	if(typeof(textObj) == 'object' && textObj.caretPos)
	{
		textObj.caretPos.text+=ids;
	}
	else
	{
		var specValue = $("#specCode").val() +ids;
		$("#specCode").val(specValue);
	}
	remove();
	return false;
}

function insertRelativeIds(ids){
	$("#relative").val($("#relative").val() +ids);
	remove();
	return false;
}

function setCaret(o){
	textObj = o;
	if(textObj.createTextRange){
		textObj.caretPos=document.selection.createRange().duplicate();
	}
}
</script>
</body>
</html>